<template>
    <div>
        <!-- :rules="rules"   prop 校验规则-->
        <el-form ref="uservo" :model="uservo" label-width="80px" class="loginForm">

            <el-form-item label="手机号" prop="phone">
                <el-input v-model="uservo.phone"></el-input>
            </el-form-item>

            <el-form-item label="密码" prop="password">
                <el-input v-model="uservo.password"></el-input>
            </el-form-item>





            <el-form-item>
                <el-button type="primary" @click="login">登录</el-button>
                <el-button type="primary" @click="registed">立即注册</el-button>
            </el-form-item>

        </el-form>
    </div>
</template>
<script>

    export default {
        data() {

            return {

                uservo: {},


            }
        },
        mounted() {

        },

        methods: {




            login() {

                this.$axios.get("/users/login", {
                    params: {
                        phone: this.uservo.phone,
                        password: this.uservo.password,

                    }
                })
                    .then(resp => {
                        if (resp.data.code == 200) {

                            this.$message({
                                message: '登录成功',
                                type: 'success'
                            });
                            //跳转
                            this.$router.push('/main')
                        } else {
                            this.$message.error("登录失败")
                        
                        }
                    })
            },

            registed() {

                this.$router.push('/Registed')

            }

        }
    }
</script>
<style>
    .loginForm {
        padding-top: 100px;
        width: 500px;
        margin: 0px auto;
    }
</style>